package model

import "gorm.io/gorm"

type Result struct {
	Code int         `json:"code"`
	Msg  string      `json:"message"`
	Data interface{} `json:"data"`
}

type ResultList struct {
	Code  int         `json:"code"`
	Msg   string      `json:"message"`
	Count int64       `json:"count"`
	Data  interface{} `json:"data"`
}

// OkData 成功的数据返回
func OkData(data interface{}, msg string) Result {
	return Result{Code: 0, Data: data, Msg: msg}
}

// OkDataList 成功的List数据返回
func OkDataList(data interface{}, msg string, count int64) ResultList {
	return ResultList{Code: 0, Data: data, Msg: msg, Count: count}
}

// Fail 失败的消息返回
func Fail(msg string) Result {
	return Result{Code: -1, Data: nil, Msg: msg}
}

type Models struct {
	gorm.Model
	CreateBy uint
	UpdateBy uint
	DeleteBy uint
	Status   string
}
